<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Look Somethings</title>
</head>
<body>
<div>
	<h2>Look Somethings</h2>
</div>

<div>
	<script type="text/javascript">
		function setPar() {
			
		}
	</script>
	<?php 
	// 数据库连接
	$con = mysqli_connect("localhost","root","root");
	if (!$con) {
	  die('Could not connect: ' . mysql_error());
	} else {
		echo '数据库连接成功';
	}

	// 选择哪个数据库
	$ret = mysqli_select_db($con, "mymessageboard");
	if ($ret) {
		echo "<br>有这个数据库<br>";
	} else {
		echo "<br>没有这个数据库<br>";
	}

	$sql = "select * from Persons order by id";
	$ret = mysqli_query($con, $sql);
	if (!$ret) {
		echo "表是空的";
	} else {
		$index = 0;
		$h = "";
		while ($row = mysqli_fetch_array($ret)) {

		$ss =  "id = " . $row["id"] . ", name = " . $row["name"] . ",age = " . $row["age"] . ",email = " . $row["email"] . ",createtime = " . $row["createtime"] . "<br>"; 

		// 拼接参数
		$par =  "id=" . $row["id"] . "&name=" . $row["name"] . "&age=" . $row["age"] . "&email=" . $row["email"] . "&createtime=" . $row["createtime"]; 

		$h .= "<a href='writesomething.php?" . $par . "'>" . $ss . "</a>";

		$arr[$index] = array("id"=>$row["id"], 
							 "name"=>$row["name"],
							 "age"=>$row["age"],
							 "email"=>$row["email"],
							 "createtime"=>$row["createtime"]);
		$index++;
	}

	echo $h;


	echo "<br>";
	echo json_encode($arr);
	
	}
	
	mysqli_close($con);
	?>
</div>

</body>
</html>